/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sgt.onlinetest.hibernatedao;

import org.hibernate.Session;
import org.hibernate.criterion.Expression;
import sgt.onlinetest.entity.Question;
import sgt.onlinetest.entity.QuestionCategory;

/**
 *
 * @author Administrator
 */
public class HibernateQuestionCategoryDAO extends HibernateGenericDAO<QuestionCategory, Long> {

    public HibernateQuestionCategoryDAO(Session session) {
        super(session);
    }

    public QuestionCategory getRoot() {
        return (QuestionCategory) getSession().createCriteria(QuestionCategory.class).add(Expression.and(Expression.eq("name", "root"), Expression.isNull("parent"))).uniqueResult();
    }
}
